package com.ai.ly.goodsautocat.vo;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;

import com.ai.ly.goodsautocat.common.Constants;

public class TrainningSampleVO extends SampleVO{
    
    private double y;

    public TrainningSampleVO(int xLength, double y) {
        super(xLength);
        this.y = y;
    }

    public double getY() {
        return y;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder(
                xLength * 2 + 1 + Constants.lineSeparator.length());
        for (int i = 0; i < xLength; i++) {
            sb.append(getWordCount(i)).append(Constants.SPLIT_BLANK);
        }
        sb.append(y);
        sb.append(Constants.lineSeparator);
        return sb.toString();
    }

    public String getIndexCountAndYStr() {
        List<Integer> list = new ArrayList<>(indexCountMap.size());
        for (Map.Entry<Integer, Integer> entry : indexCountMap.entrySet()) {
            list.add(entry.getKey());
        }
        Collections.sort(list);
        StringBuilder sb = new StringBuilder();
        for (Integer integer : list) {
            sb.append(integer).append(getWordCount(integer));
        }
        sb.append(y);
        return sb.toString();
    }
    
}
